package tech.aistar.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.aistar.entity.authordis.NoteAuthor;
import tech.aistar.entity.noteshow.ApplyTraveler;

/**
 * Created by Dell on 2019/9/29.
 */
public interface ApplyTravelerMapper {

    /**
     * @Description:旅行达人申请信息
     * @param:
     * @author XiaoDi
     * @date 2019/9/29 9:32
    */

    //查看是否为达人  - 游记个人信息查询达人状态
    @Select("select * from note_author where user_id = #{value}")
    NoteAuthor findTraveler(Integer user_id);

    //像申请表中插入信息
    //注意一个问题 $和#的区别  $只能在使用Integer时,变量名称不必用value
   // @Insert("insert into apply_traveler(user_id,note_author_id,apply_name,phone,provice,city,intro) values(${noteAuthor.userId},${noteAuthor.id},#{applyTraveler.applyName},#{applyTraveler.phone},#{applyTraveler.provice},#{applyTraveler.city},#{applyTraveler.intro})")
    //void applyTravler(@Param("NoteAuthor") NoteAuthor noteAuthor, @Param("applyTraveler") ApplyTraveler applyTraveler);
    @Insert("insert into apply_traveler(user_id,note_author_id,apply_name,phone,provice,city,intro) values(#{userId},#{noteAuthorId},#{applyName},#{phone},#{provice},#{city},#{intro})")
    void applyTravler(ApplyTraveler applyTraveler);

    //更新游记作者表的信息
    @Update("update note_author set flag = 1 where user_id = ${userId} ")
    void updateTraveler(Integer user_id);

    //把数据更新到达人表
    @Insert("insert into traveler(per_id,note_author_id) values(${userId},${noteAuthorId})")
    void addTravler(ApplyTraveler applyTraveler);


}
